﻿using System;
using Tao.OpenGl;

namespace Aeon.Framework.Objects
{

/// <summary>
/// Line primitive class.
/// Uses up to 1 color.
/// 
/// </summary>
public class Line : ObjectBase
    {
    // --- Attributes:
    
    private Single length;  // Line width.
    
    // --- Constructor:

    /// <summary>
    /// Line constructor.
    /// 
    /// </summary>
    /// <param name="key"> Unique identifier. </param>
    /// <param name="origin"> Object origin.  </param>
    /// <param name="angle"> Object orientation. </param>
    /// <param name="size"> Line length. </param>
    public Line(String key, Position origin, Orientation angle, Single size)
        : base(key,origin,angle,AeonMaterials.Default)
        {
        
        length = size;
        }
        
    // --- Public Methods:

    public override void Draw()
        {
        Gl.glTranslatef(origin.xPos,origin.yPos,origin.zPos);
        Gl.glRotatef(angle.xAng,1,0,0);
        Gl.glRotatef(angle.yAng,0,1,0);
        Gl.glRotatef(angle.zAng,0,0,1);
        
        Gl.glColor4f(material.Color.R, material.Color.G, material.Color.B, material.Color.A);
        
        Gl.glBegin(Gl.GL_LINES);
        Gl.glNormal3i(0,1,0);
        
        Gl.glVertex3f(0, 0, 0);
        Gl.glVertex3f(length, 0, 0);
        
        Gl.glEnd();
        }

    }


}